#ifndef MYAUDIOPLAYER_H
#define MYAUDIOPLAYER_H
#include <QAudioSink>
#include <QMediaDevices>
#include <QObject>
#include "MyIODevice.h"

class MyAudioPlayer : public QObject
{
    Q_OBJECT
public:
    explicit MyAudioPlayer(QObject *parent = nullptr);
    ~MyAudioPlayer();
    void chooseOutputDevice(uint8_t index);
    void onPause();
    void onResume();
    void startPlay();
    void stopPlay();
    void replay();
    QVector<QString> getOutputDevicesDescription();
signals:

protected slots:
    void onAudioVloumeChange(float value);

private:
    QAudioSink *audioSinkOutput;
    QMediaDevices *MediaDevices;
    QList<QAudioDevice> outputDevices;
    QAudioDevice selectOutputDevices;
    MyIODevice *myIODevice;
    QVector<QString> outputDevicesDescription;
    float volume;
    bool startplaying; //这个问题就是切换时，可能都没有播放，导致访问未初始化的指针
};

#endif // MYAUDIOPLAYER_H
